﻿namespace Hippo.Console.Lib
{
    using Properties;
    using Hippo.Common;

    public class ConsoleCommandLineParser : CommandLineParser
    {
        private readonly RegexFactory regexFactory;

        public ConsoleCommandLineParser(IConfigurationProfile configuration, RegexFactory regexFactory) : 
            base(configuration)
        {
            this.regexFactory = regexFactory;
        }

        public override OptionSet CreateCommandLineOptions()
        {
            return new OptionSet
            {
                { 
                    "/waitFor=STR", 
                    ConsoleOptions.WaitForAgentsDescription, 
                    regexFactory.GetArgumentExpression("waitFor", "wf"), 
                    value => Configuration.Set(ConsoleConfigurationProfile.WaitForAgentsIdentifier, value)
                },
                { 
                    "/waitTimeout=X", 
                    ConsoleOptions.WaitTimeoutDescription, 
                    regexFactory.GetArgumentExpression("waitTimeout", "wt"), 
                    value => Configuration.Set(ConsoleConfigurationProfile.WaitTimeoutIdentifier, value)
                },
                { 
                    "/reportsPath=STR", 
                    ConsoleOptions.ReportsPathDescription, 
                    regexFactory.GetArgumentExpression("reportPath", "rp"), 
                    value => Configuration.Set(ConsoleConfigurationProfile.ReportsPathIdentifier, value)
                },
                { 
                    "/help", 
                    "Get command line help (Short format: /?)", 
                    regexFactory.HelpArgumentExpression, 
                    value => GetHelp(ConsoleOptions.CommandLineHelp, ExitCode.Normal)
                },
            };
        }
    }
}
